package ai.esc.speedy.admin.user.domain.valueobject;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.springframework.data.domain.Page;

import java.util.ArrayList;
import java.util.List;

/**
 * @author SAGE
 * @version v1 2019/5/28 15:07
 */
@Data
public class SimplePage {

    @JsonIgnore
    private Page page;

    public SimplePage() {
    }

    public SimplePage(Page page) {
        if (page != null) {
            this.page = page;
            this.content = page.getContent();
            this.totalPages = page.getTotalPages();
            this.size = page.getSize();
            this.last = page.isLast();
            this.number = page.getNumber();
            this.totalElements = page.getTotalElements();
        }
    }

    /**
     * 数据列表
     */
    private List content = new ArrayList<>();

    /**
     * 总条数
     */
    private long totalElements;

    /**
     * 总页数
     */
    private int totalPages;

    /**
     * 每页多少条数据
     */
    private int size;
    /**
     * 当前页
     */
    private int number;

    /**
     * 是否最后一条数据
     */
    private boolean last;

}
